public class Test {


    //202.快乐数
    public int SquareSum(int n) {
        int sum=0;
        while(n!=0) {
            sum+=(n%10)*(n%10);
            n/=10;
        }
        return sum;
    }
    public boolean isHappy(int n) {
        int slow = n;
        int fast = n;
        while(true) {
            slow = SquareSum(slow);
            fast = SquareSum(fast);
            fast = SquareSum(fast);
            if(fast == slow) break;
        }
        if(slow == 1) {
            return true;
        }
        return false;
    }
    //08.01三步问题
    public int waysToStep(int n) {
        int[] dp = new int[n+1];
        if(n==1) return 1;
        if(n==2) return 2;
        if(n==3) return 4;
        dp[3]=4;dp[1]=1;dp[2]=2;
        for(int i=4;i<n+1;i++) {
            dp[i]=(dp[i-1]+(dp[i-2]+dp[i-3])%1000000007)%1000000007;
        }
        return dp[n];
    }

}
